function uifftview_UpdateFcn(vid, e, h)
%UIFFTVIEW_UPDATEFCN Summary of this function goes here
%   Detailed explanation goes here

h_img = findobj('tag', 'uifftview', 'type', 'image');
if isempty(h_img), return; end

if IsRGB(e.Data)
    gray= rgb2gray(e.Data);
else
    gray= e.Data;
end

h_rect= getappdata(h, 'FFTROIHandle');
fft_roi= getPosition(h_rect);
fft_data= gray((1:fft_roi(4))+fft_roi(2), (1:fft_roi(3)))+fft_roi(2);

psd=signal2pds(fft_data);
I= pds2gray(psd);
set(h_img, 'CData', I)
end

function bool= IsRGB(frame)

[~, ~, dim]= size(frame);

switch dim
    case 1, bool= false;
    case 3, bool= true;
    otherwise, bool= false;
end

end

